package com.huage_04;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huage_02.lesson_01.Student;

import java.util.ArrayList;
import java.util.List;

public class JedisDemo {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<Student>();
        Student std1 = new Student("张三","男");
        Student std2 = new Student("李四","男");
        list.add(std1);
        list.add(std2);
        //序列化list为json
        ObjectMapper mapper = new ObjectMapper();
        try {
            String json = mapper.writeValueAsString(list);
            System.out.println(json);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
    }
}
